﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoShopping.Model;

namespace GoShopping.BLL.Orders
{
    /// <summary>
    /// 发货单
    /// </summary>
    public class InvoiceBean
    {
        public IList<Invoice> GetAll()
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.Invoice).ToList<Invoice>();
        }

        public Invoice GetOne(int invoiceID)
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.Invoice).Where(
                GoShoppingOrderNBear.Invoice.ID == invoiceID).ToSingleObject<Invoice>();
        }

        public Invoice GetByOrderCode(int orderCode)
        {
            return Databases.DBGoShoppingOrder.Select(
                GoShoppingOrderNBear.Invoice).Where(
                GoShoppingOrderNBear.Invoice.OrderID == orderCode).ToSingleObject<Invoice>();
        }

        public int Insert(Invoice invoice)
        {
            return Databases.DBGoShoppingOrder.Insert(
                GoShoppingOrderNBear.Invoice).AddColumn(
                GoShoppingOrderNBear.Invoice.IsInsurance, invoice.IsInsurance).AddColumn(
                GoShoppingOrderNBear.Invoice.OrderID, invoice.OrderID).AddColumn(
                GoShoppingOrderNBear.Invoice.ReceiveUserName, invoice.ReceiveUserName).AddColumn(
                GoShoppingOrderNBear.Invoice.RecordPersonID, invoice.RecordPersonID).AddColumn(
                GoShoppingOrderNBear.Invoice.Remarks, invoice.Remarks).AddColumn(
                GoShoppingOrderNBear.Invoice.ReveiveUserAddress, invoice.ReveiveUserAddress).AddColumn(
                GoShoppingOrderNBear.Invoice.SendDate, invoice.SendDate).AddColumn(
                GoShoppingOrderNBear.Invoice.Sender, invoice.Sender).AddColumn(
                GoShoppingOrderNBear.Invoice.SendFee, invoice.SendFee).AddColumn(
                GoShoppingOrderNBear.Invoice.SendType, invoice.SendType).ExecuteReturnAutoIncrementID(
                GoShoppingOrderNBear.Invoice.ID);
        }
    }
}
